package com.webfinal.backsystem.controller;

import com.webfinal.backsystem.dao.ProductTypeMapper;
import com.webfinal.backsystem.request.prosucttype.AddProTypeRequest;
import com.webfinal.backsystem.request.prosucttype.SearchByNameRequest;
import com.webfinal.backsystem.request.prosucttype.UpdateProTypeRequest;
import com.webfinal.backsystem.response.producttype.AddProTypeResponse;
import com.webfinal.backsystem.response.producttype.SearchByNameResponse;
import com.webfinal.backsystem.response.producttype.UpdateProTypeResponse;
import com.webfinal.backsystem.service.ProductTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class ProductTypeController {
    @Autowired
    private ProductTypeService productTypeService;

    @RequestMapping(value = "/api/producttype/searchbyname")
    public SearchByNameResponse searchtypebyname(@RequestBody SearchByNameRequest searchByNameRequest){
        SearchByNameResponse response = productTypeService.searchProductTypeByName(searchByNameRequest);
        return response;
    }

    @RequestMapping(value = "/api/producttype/addtype")
    public AddProTypeResponse addtype(@RequestBody AddProTypeRequest addProTypeRequest){
        AddProTypeResponse response = productTypeService.addProductType(addProTypeRequest);
        return response;
    }

    @RequestMapping(value = "/api/producttype/updatetype")
    public UpdateProTypeResponse updatetype(@RequestBody UpdateProTypeRequest updateProTypeRequest){
        UpdateProTypeResponse response = productTypeService.updateProductType(updateProTypeRequest);
        return response;
    }
}
